//
// Calc.cpp for 203 Poisson in /home/druart_p/Work/math/my-math-epi/203
//
// Made by pierrick druart
// Login   <druart_p@epitech.net>
//
// Started on  Tue Mar 20 09:17:49 2012 pierrick druart
// Last update Tue Mar 27 23:36:37 2012 pierrick druart
//

#include <math.h>

#include "Calc.hh"

Calc::Calc()
{
}

Calc::~Calc() {}

double	Calc::fact(double x)
{
  if (x == 0 || x == 1)
    return 1;
  return x * this->fact(x - 1);
}

double	Calc::loiBinomiale(double n, double k)
{
  return this->fact(n) / (this->fact(k) * this->fact(n - k));
}

double	Calc::loiDiscreteBinomiale(double n, double p, double k)
{
  return this->loiBinomiale(n, k) * pow(p, k) * pow((1 - p), n - k);
}

double	Calc::loiPoisson(double l, int k)
{
  return exp(-l) * (pow(l, k) / this->fact((double)k));
}
